<template>
  <div style="padding-left: 30px">
    <div style="line-height: 34px;font-weight: bolder;font-size: 25px;">
      买车订单
    </div>
    <el-table
        :data="tableData"
        style="width: 100%">
      <el-table-column type="expand">
        <template slot-scope="props">
          <el-form label-position="left" inline class="demo-table-expand">
            <el-form-item label="车辆品牌">
              <span>{{ props.row.brand }}</span>
            </el-form-item>
            <el-form-item label="所属卖家">
              <span>{{ props.row.seller }}</span>
            </el-form-item>
            <el-form-item label="订单 ID">
              <span>{{ props.row.id }}</span>
            </el-form-item>
            <el-form-item label="总金额">
              <span>{{ props.row.money }}</span>
            </el-form-item>
            <el-form-item label="所在区域">
              <span>{{ props.row.address }}</span>
            </el-form-item>
            <el-form-item label="商品描述">
              <span>{{ props.row.title }}</span>
            </el-form-item>
            <el-form-item label="订金金额">
              <span>
                {{ props.row.firstMoney }}元
                <span v-if="props.row.status!=0&&props.row.status!=6">，支付时间（{{ props.row.gmtFirstMoney }}）</span>
              </span>
            </el-form-item>
            <el-form-item label="尾款金额">
            <span>{{ props.row.lastMoney }}元
              <span v-if="props.row.status!=0&&props.row.status!=6&&props.row.status!=1">，支付时间（{{ props.row.gmtLastMoney }}）</span>
            </span>
            </el-form-item>
          </el-form>
        </template>
      </el-table-column>
      <el-table-column
          :show-overflow-tooltip="true"
          align="center"
          label="订单 ID"
          prop="id">
      </el-table-column>
      <el-table-column
          width="100"
          align="center"
          label="车辆品牌"
          prop="brand">
      </el-table-column>
      <el-table-column
          :show-overflow-tooltip="true"
          width="200"
          align="center"
          label="描述"
          prop="title">
      </el-table-column>
      <el-table-column
          align="center"
          label="订单状态"
          show-overflow-tooltip>
        <template slot-scope="scope" >
          <span v-if="scope.row.status==0">订金（元）：{{scope.row.firstMoney}}</span>
          <span v-else-if="scope.row.status==1">尾款（元）：{{scope.row.lastMoney}}</span>
          <span v-else-if="scope.row.status==2">待卖家发车</span>
          <span v-else-if="scope.row.status==3">待收车</span>
          <span v-else-if="scope.row.status==4">待双方完成订单</span>
          <span v-else-if="scope.row.status==5">订单已完成</span>
          <span v-else-if="scope.row.status==6">订单已取消</span>
          <span v-else-if="scope.row.status==7" style="color: #ff443a">订单异常</span>
          <span v-else-if="scope.row.status==8" style="color: #ff443a">订单已过期</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button  type="primary" icon="el-icon-edit" circle @click="pay(scope.row.id)"></el-button>
        </template>
      </el-table-column>
    </el-table>
    <!--    分页-->
    <div style="text-align: center;margin-top: 20px">
      <el-pagination
          background
          @current-change="changePage"
          layout="total, prev, pager, next"
          :total=total
          :current-page=currentPage
          :pageSize=pageSize>
      </el-pagination>
    </div>
  </div>
</template>

<script>

export default {
  data() {
    return {
      tableData: [],
      total:"",
      pageSize:"",
      currentPage:1,
    }
  },
  methods:{

    changePage(value){
      this.$router.replace('?page='+value);
      this.loadListHandler();
    },
    loadListHandler(){
      let _this=this;
      let page=this.$router.currentRoute.query.page;
      if (!page){
        page=1
      }
      _this.http.get('/xiaoming-order/order/select-list/'+page).then(function (response) {
        _this.tableData=response.data.data.list;
        _this.total=response.data.data.total;
        _this.pageSize=response.data.data.pageSize;
        _this.currentPage=response.data.data.currentPage;
      })
    }
  },
  mounted() {
    this.loadListHandler();
  }
}
</script>
<style>
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
.ccc{
  border: 2px solid #0aa1ed
}
</style>